package com.accenture.automation.biz.api.interfaces;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.accenture.automation.biz.api.bean.ResponseBaseBean;
import com.accenture.automation.biz.api.producer.iface.ProducerService;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value = "/ITE")
public class AccountPostInterface {
	@Autowired
	ProducerService producerService;

	@Value("${TOPIC}")
	private String TOPIC;

	/**
	 * = accountUrl=上抛对方系统接口地址 accountPK=本条业务唯一主键
	 */
	@ApiOperation(value = "accountPost", notes = "ITE上抛接口")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "accountPostApp", value = "上抛系统名", paramType = "path", dataType = "String"),
			@ApiImplicitParam(name = "accountInid", value = "接口编码", paramType = "path", dataType = "String"),
			@ApiImplicitParam(name = "accountPK", value = "上抛主键", paramType = "path", dataType = "String") })
	@RequestMapping(value = "/accountPostApp/{accountPostApp}/accountInid/{accountInid}/accountPK/{accountPK}", method = RequestMethod.POST)
	@ResponseBody
	public Object accountPost(@RequestBody String body, @PathVariable String accountPostApp,
			@PathVariable String accountInid, @PathVariable String accountPK, HttpServletRequest request,
			HttpServletResponse response) {
		ResponseBaseBean<Object> rsBean = producerService.apiCreate(TOPIC, body,
				accountPostApp + "_" + accountInid + "_" + accountPK);
		return rsBean;
	}

}
